const clipboardy = require("clipboardy");
const { warn } = require("../utils/log_tool");
const { BaseCommand } = require("./base");

class WriteClipboard extends BaseCommand {
    async execute() {
        const _data = this.selfData;
        const content =
            typeof this.content === "string"
                ? this.content
                : JSON.stringify(this.content);
        try {
            clipboardy.writeSync(content);
        } catch (_error) {
            warn("写入剪切板失败");
        }
    }

    getRequireContent() {
        return true;
    }
}

module.exports = {
    WriteClipboard,
};
